<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    .mt2 {
        margin-top: 20px;
    }

    .flex {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .span {
        color: #000;
        font-weight: bold;
    }
    .layui-col-md3{
        margin-bottom: 10px;
    }
</style>
<div class="layui-bg-gray" style="padding: 16px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">单位信息</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space1">
                        <div class="layui-col-md3">
                            <div>单位名称：<span class="span" th:text="${memberApply.name}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==2}">
                            <div>发证单位：<span id="issueUnit" class="span" th:text="${memberApply.issueUnit}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>申请时间：<span id="createDate" class="span"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>单位类型(企业规模）：<span id="type" class="span" th:text="${memberApply.type}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>在岗职业人数：<span id="peopleNum" class="span" th:text="${memberApply.peopleNum}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>所属行业：<span id="trade" class="span" th:text="${memberApply.trade}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>是否为产教融合型企业：<span id="isEnterprise" class="span" th:text="${#strings.listSplit('国家级,省级,否',',')[memberApply.isEnterprise]}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>企业类型：<span id="enterpriseType" class="span" th:text="${memberApply.enterpriseType}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>申请意向：<span id="intention" class="span" th:text="${#strings.listSplit('常务副理事单位,副理事单位,常务理事单位,理事单位',',')[memberApply.intention]}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>统一社会信用代码：<span id="socialCreditCode" class="span" th:text="${memberApply.socialCreditCode}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType!=3}">
                            <div>单位性质：<span id="ship" class="span" th:text="${memberApply.ship}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType!=3}">
                            <div>申请意向：<span id="intention" class="span" th:text="${#strings.listSplit('常务副理事单位,副理事单位,常务理事单位,理事单位',',')[memberApply.intention]}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType!=3}">
                            <div>学校/机构代码：<span id="schoolOrgCode" class="span" th:text="${memberApply.schoolOrgCode}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>单位地址：<span id="address" class="span" th:text="${memberApply.address+' '+memberApply.detailAddress}"></span></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <input id="id" name="id" th:value="${memberApply.id}" type="hidden">
        <input id="applicationForm2" name="id" th:value="${memberApply.applicationForm}" type="hidden">
        <input id="constructionCertificate2" name="id" th:value="${memberApply.constructionCertificate}" type="hidden">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">联系人信息</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space1">
                        <div class="layui-col-md3">
                            <div>法人代表：<span class="span" th:text="${memberApply.legalRepresentative}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>办公电话：<span id="officePhone" class="span" th:text="${memberApply.officePhone}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>法人手机号：<span id="legalPhone" class="span" th:text="${memberApply.legalPhone}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>法人邮箱：<span id="legalMail" class="span" th:text="${memberApply.legalMail}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>推荐代表：<span id="recommend" class="span" th:text="${memberApply.recommend}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>职务：<span id="post" class="span" th:text="${memberApply.post}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>职称：<span id="position" class="span" th:text="${memberApply.position}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>所在部门：<span id="department" class="span" th:text="${memberApply.department}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>推荐人手机号：<span id="recommPhone" class="span" th:text="${memberApply.recommPhone}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>推荐人邮箱号：<span id="recommMail" class="span" th:text="${memberApply.recommMail}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>通信地址：<span id="commAddress" class="span" th:text="${memberApply.commAddress}"></span></div>
                        </div>
                        <div class="layui-col-md3" th:if="${memberApply.unitType==3}">
                            <div>核心产品（服务）名称：<span id="coreProductName" class="span" th:text="${memberApply.coreProductName}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>备注：<span id="remark" class="span" th:text="${memberApply.remark}"></span></div>
                        </div>
                        <div class="layui-col-md6">
                            <div>申请表：
                                <a id="applicationForm" class="span" th:text="${memberApply.applicationForm}" onclick="preview('applicationForm2')"></a>
                                <a style="margin-left: 10px" type="button" title="下载" class="layui-btn layui-btn-sm" onclick="dow('applicationForm2')">
                                    <i class="fa fa-paper-plane-o"></i>
                                </a>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div>参与单位建设证明：
                                <a id="constructionCertificate" class="span" th:text="${memberApply.constructionCertificate}" onclick="preview('constructionCertificate2')"></a>
                                <a style="margin-left: 10px" type="button" title="下载" class="layui-btn layui-btn-sm" onclick="dow('constructionCertificate2')">
                                    <i class="fa fa-paper-plane-o"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">制证信息</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space1">
                        <div class="layui-col-md3">
                            <div>聘书姓名：<span class="span" th:text="${memberApply.contractName}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>邮寄地址：<span class="span" th:text="${memberApply.mailingAddress}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>收件人姓名：<span class="span" th:text="${memberApply.addresseeName}"></span></div>
                        </div>
                        <div class="layui-col-md3">
                            <div>收件人联系电话：<span class="span" th:text="${memberApply.addresseePhone}"></span></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">审核信息</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space1">
                        <div class="layui-col-md12" th:if="${memberApply.checkStatus!=1}">
                            <div>审核状态：<span class="span">待审核</span></div>
                        </div>
                        <div class="layui-col-md12" th:if="${memberApply.checkStatus!=1}">
                            <div>审核结果：<span class="span">-</span></div>
                        </div>
                        <div class="layui-col-md12" th:if="${memberApply.checkStatus!=1}">
                            <div>审核时间：<span class="span">-</span></div>
                        </div>
                        <div class="layui-col-md12" th:if="${memberApply.checkStatus==1}">
                            <div class="layui-timeline" id="layui-timeline">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12" id="check" th:if="${memberApply.checkStatus!=1}">
            <div class="layui-card flex">
                <div style="width: 300px;padding-right: 20px">
                    <button type="button" class="layui-btn layui-btn-normal layui-btn-radius layui-btn-fluid" onclick="checkMemberApply(0)">通过</button>
                </div>
                <div style="width: 300px;padding-left: 20px">
                    <button type="button" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-fluid" onclick="checkMemberApply(1)">拒绝</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
</script>
<script>
    var prefix = "/jzweb/memberApply";
    function getInfo() {
        var loadIndex = layer.msg('请稍后...', {
            icon: 16,
            shade: 0.01,
            time: 1000*30
        });
        $.ajax({
            url : prefix+"/getInfo",
            cache : true,
            type : "get",
            data : {
                id:$('#id').val()
            },// 你的formid
            async : false,
            success : function(r) {
                layer.close(loadIndex)
                if(r.code==0){
                    let createDate = $('#createDate')
                    createDate.html(r.data.createDate);
                }
                if (r.code==0&& r.data.checkStatus==1) {
                    r.data.checkRecordDOS.forEach(item => {
                        if(item.checkStatus==1){
                            $('#check').hide();
                        }
                        if(item.checkResult==0){
                            $('#layui-timeline').append(`
                            <div class="layui-timeline-item">
                                <div class="layui-timeline-content layui-text"><i class="layui-icon layui-timeline-axis"></i>
                                    <div class="mt2">审核状态：<span class="">已审核</span></div>
                                    <div class="mt2">审核结果：<span class="">通过</span></div>
                                    <div class="mt2">审核时间：<span class="">${item.createDate}</span></div>
                                </div>
                            </div>`)
                        }else{
                            $('#layui-timeline').append(`
                            <div class="layui-timeline-item">
                                <div class="layui-timeline-content layui-text"><i class="layui-icon layui-timeline-axis"></i>
                                    <div class="mt2">审核状态：<span class="">已审核</span></div>
                                    <div class="mt2">审核结果：<span class="">已拒绝</span></div>
                                    <div class="mt2">拒绝原因：<span class="">${item.reason}</span></div>
                                    <div class="mt2">审核时间：<span class="">${item.createDate}</span></div>
                                </div>
                            </div>`)
                        }
                    });
                }
            }
        });
    }
    function dow(id) {
        let url = $('#'+id).val();
        let a = document.createElement('a');
        a.href = url;
        a.download = url;
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
    }
    function preview(id) {
        let url = $('#'+id).val();
        window.open(url, "_blank");
    }
    function checkMemberApply(type=0){
        layer.confirm(`您确定要${type==0?'通过':'拒绝'}吗？`, {
            btn1:function(index){
                if(type==1){
                    layer.closeAll();
                    layer.prompt({title: '请输入拒绝原因', formType: 2}, function(value, index, elem){
                        console.log(value, index, elem)
                        if(value === '') return elem.focus();
                        var loadIndex = layer.msg('请稍后...', {
                            icon: 16,
                            shade: 0.01,
                            time: 1000*30
                        });
                        $.ajax({
                            url : prefix+"/checkMemberApply",
                            type : "get",
                            data : {
                                'id' : $('#id').val(),
                                reason : value,checkResult:type
                            },
                            success : function(r) {
                                layer.close(loadIndex)
                                if (r.code==0) {
                                    layer.msg(r.msg);
                                    getInfo()
                                    setTimeout(()=>{
                                        var index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
                                        parent.layer.close(index); // 再执行关闭
                                    },1000)
                                }else{
                                    layer.msg(r.msg);
                                    getInfo()
                                    setTimeout(()=>{
                                        var index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
                                        parent.layer.close(index); // 再执行关闭
                                    },1000)
                                }
                            }
                        });
                        // // 关闭 prompt
                        layer.closeAll();
                    });
                    return
                }
                var loadIndex2 = layer.msg('请稍后...', {
                    icon: 16,
                    shade: 0.01,
                    time: 1000*30
                });
                $.ajax({
                    url : prefix+"/checkMemberApply",
                    type : "get",
                    data : {
                        'id' : $('#id').val(),
                        checkResult:type,
                        reason:''
                    },
                    success : function(r) {
                        layer.close(loadIndex2)
                        if (r.code==0) {
                            layer.closeAll();
                            layer.msg(r.msg);
                            reLoad();
                        }else{
                            layer.closeAll();
                            layer.msg(r.msg);
                        }
                    }
                });
            }
        });
    }
    function timestampToTime(timestamp) {
        var date = new Date(timestamp)//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        var Y = date.getFullYear() + '-';
        var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
        var D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
        var h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
        var m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
        var s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
        return Y+M+D+h+m+s;
    }
    $().ready(function () {
        getInfo()
        let applicationForm = $('#applicationForm').text()
        let constructionCertificate = $('#constructionCertificate').text()
        if(applicationForm){
            const text = applicationForm.split('/')[applicationForm.split('/').length-1];
            $('#applicationForm').text(text)
        }
        if(constructionCertificate){
            const text = constructionCertificate.split('/')[constructionCertificate.split('/').length-1];
            $('#constructionCertificate').text(text)
        }
    });
</script>
</body>
</html>
